package org.example.mppg.Initializer;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.mppg.MpPgApplication;
import org.example.mppg.domain.entity.Student;
import org.example.mppg.domain.entity.Teacher;
import org.example.mppg.logic.service.IStudentService;
import org.example.mppg.logic.service.ITeacherService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;


@RunWith(SpringRunner.class)
@SpringBootTest(classes = MpPgApplication.class)
@Slf4j
public class DataInitializer {

    @Resource
    private IStudentService studentService;

    @Resource
    private ITeacherService teacherService;

    @Test
    public void initStudents() {
        List<Student> students = Student.GenerateStudents(2);
        studentService.saveBatch(students);
    }

    @Test
    public void studentList() {
        LambdaQueryWrapper <Student> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.last("limit 10");
        List<Student> list = studentService.list(queryWrapper);
        for (Student student : list) {
            log.info("学生信息:{}", student.getAddressGeo());
        }
    }
    @Test
    public void initTeachers() {
        List<Teacher> teachers = Teacher.GenerateTeachers(1);
        teacherService.saveBatch(teachers);
    }

    @Test
    public void ListTeachers() {
        LambdaQueryWrapper<Teacher> wrapper = new LambdaQueryWrapper<>();
        List<Teacher> list = teacherService.list(wrapper);
        log.info("-----打印日志------{}",list.size() );
        log.warn("测试的");
    }
}